<script>

import * as echarts from 'echarts';
// import $ from 'jquery'
export default {
  name: 'VisualizationNine',
  data() {
    return{

    }
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData() {
      this.$axios.get('/api/vis/data10', {}).then(res => {
        if (res.data.code === 20041) {
          let data = [];
          for (let i = 0; i < res.data.data.length; i++) {
            if(res.data.data[i].param1 === "提供") {
              data.push(
                  { value: res.data.data[i].param2,
                    name: res.data.data[i].param1 },

              );
            }
          }
          data.push(
              { value: (13400 - 12268),
                name: "其他" },

          );
          this.init(data)
        }
      }).catch(error => {
        this.open4(error);
      })
    },
    open4(msg) {
      this.$notify.error({
        title: msg,
        message: '这是一条错误的提示消息'
      });
    },
    init(data) {
      var chartDom = document.getElementById('main9');
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        color: ["pink", "#023bff"],
        title: {
          text: '是否提供发票统计'
        },
        tooltip: {
          trigger: 'item',
          // formatter: "{a} <br/>{b} : {c} ({d}%)"
          formatter: '是否提供发票: {b} <br/> 统计数量: {c} ({d}%)' // {a}（系列名称），{b}（数据项名称），{c}（数值）, {d}（百分比）
        },
        legend: {
          top: '5%',
          left: 'center'
        },
        series: [
          {
            name: '出租方式',
            type: 'pie',
            radius: ['40%', '70%'],
            avoidLabelOverlap: false,
            itemStyle: {
              borderRadius: 10,
              borderColor: '#fff',
              borderWidth: 2
            },
            label: {
              show: false,
              position: 'center'
            },
            emphasis: {
              label: {
                show: true,
                fontSize: 40,
                fontWeight: 'bold'
              }
            },
            labelLine: {
              show: false
            },
            data: data
          }
        ]
      };

      option && myChart.setOption(option);
    }
  }

}
</script>

<template>
  <div id="main9"></div>
</template>

<style scoped>
#main9 {
  width: 100%;
  height: 100%;
}
</style>